import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/index.vue')
  },
  {
    path: '/404',
    name: 'NotFound',
    component: () => import('@/components/sysCas/SysCas404.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue')
  }
  // 其余所有未配置路由跳转404
  // {
  //   path: '/:catchAll(.*)',
  //   redirect: '/404'
  // }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export function resetRouter() {
  // 通过添加一个名称冲突的路由 删除添加的路由
  router.addRoute({ path: '/', name: 'home', component: () => import('@/views/index.vue') })
}

export default router
